package dk.degofedal.scala.math

class Factorize(n : Int) {

	private def fact(x : Int, y : Int) : List[Int] = (x,y) match {
		case (`y`, _) => List(x)
		case _ if x % y == 0 => y :: fact(x / y, y)
		case (_, 2) => fact(x, 3)
		case _ => fact(x, nextTrail(y))
	}
	
	private def nextTrail(v : Int) = {
		v + 2
	}
	
	
	require(n > 0)
	val f = fact(n, 2)
	
}